home *** CD-ROM | disk | FTP | other *** search
- -- vars.e
- -- declarations of global variables and constants
- global constant TRUE = 1, FALSE = 0
-
- global constant CRT = 1 -- output device
-
- global constant G_SIZE = 7 -- the galaxy is a G_SIZE x G_SIZE
- -- array of quadrants
-
- global constant INVISIBLE_CHAR = ' ' + 256 -- prints as ' '
- -- but has different value
-
- global type boolean(object x)
- return x = TRUE or x = FALSE
- end type
-
- global type char(integer c)
- -- true if c is a character that can be printed on the screen
- return c >= ' ' and c <= 127 or c = INVISIBLE_CHAR
- end type
-
- global type byte(integer x)
- return x >= -1 and x <= 255
- end type
-
- global type positive_int(integer x)
- return x >= 0
- end type
-
- global type positive_atom(atom x)
- return x >= 0
- end type
-
- -----------------------------------------------------------------------------
- -- the "f" array: (objects in the current quadrant)
- -----------------------------------------------------------------------------
- global constant
- FROWS = 30, -- number of rows (objects) in the f array
- FCOLS = 12 -- number of columns in the f array
- global constant
- F_TYPE = 1, -- type of object
- F_EN = 2, -- energy
- F_TORP = 3, -- number of torpedoes
- F_DEFL = 4, -- number of deflectors
- F_FRATE = 5, -- firing rate
- F_MRATE = 6, -- moving rate
- F_TARG = 7, -- target
- F_DOCK = 8, -- docked yet?
- F_PBX = 9, -- planet/base index
- F_X = 10, -- x coordinate
- F_Y = 11, -- y coordinate
- F_UNDER = 12 -- characters underneath
-
- global sequence f
- f = repeat(repeat(0, FCOLS), FROWS)
-
- global type valid_f_row(integer x)
- -- true if x is a valid row number in the f array
- return x >= 1 and x <= FROWS
- end type
-
- global type f_row(object x)
- -- either an f_row or -1 (null value)
- return valid_f_row(x) or x = -1 or x = 0
- end type
-
- -- the f array elements always appear according to the following order
- -- where row 1 is always the Enterprise. The following variables mark
- -- the start of each group of objects, where a group may be empty:
- global constant ENTERPRISE = 1 -- row 1 is Enterprise
- -- row 2 is first planet
- -- (if any)
- global f_row
- fb1, -- first base
- fr1, -- first Romulan
- ft1, -- first Tholian
- fk1, -- first Klingon
- fnext -- first empty row
-
- -----------------------------------------------------------------------------
- -- the galaxy array: (records numbers of objects across
- -- all quadrants of the galaxy)
- -----------------------------------------------------------------------------
- global constant
- G_EN = 1, -- Enterprise (in g [1] is used to mark if Enterprise has been
- -- this quadrant)
- G_SK = 2, -- small klingon
- G_BK = 3, -- big klingon
- G_JM = 4, -- jumbo klingon
- G_RM = 5, -- romulan
- G_TH = 6, -- tholian
- G_PL = 7, -- planet
- G_BS = 8, -- base
- NTYPES = 8 -- number of different types of object
-
- global sequence otype
-
- global type object_type(integer x)
- -- is x a type of object?
- return x >= 1 and x <= NTYPES
- end type
-
- global sequence g
-
- -----------------------------------------------------------------------------
- -- the planet/base array (records info on each planet and base in the galaxy)
- -----------------------------------------------------------------------------
- global constant
- PROWS = 9, -- number of planets + bases
- PCOLS = 8 -- number of columns
- global constant
- P_EXIST = 1, -- does it exist?
- P_QR = 2, -- quadrant row
- P_QC = 3, -- quadrant column
- P_X = 4, -- x coordinate within quadrant
- P_Y = 5, -- y coordinate within quadrant
- P_EN = 6, -- energy available
- P_TORP = 7, -- torpedos available
- P_POD = 8 -- pods available (new weapon system, not yet implemented)
-
- global constant DESTROYED = 1, DOCKED_WITH = 2, NEVER_DOCKED = 3
-
- global sequence pb
- pb = repeat(repeat(0, PCOLS), PROWS)
-
- global type pb_row(integer x)
- -- is x a valid row in the planet/base array?
- return x >= 1 and x <= PROWS
- end type
-
- global type g_index(integer x)
- -- a valid row or column index into the galaxy array
- return x >= 1 and x <= G_SIZE
- end type
-
- global boolean gameover -- is game over?
-
- global g_index qrow, qcol -- current quadrant row and column
-
- ------------------
- -- Romulan status:
- ------------------
- global constant
- TRUCE = 0,
- HOSTILE = 1,
- CLOAKING = 2
-
- global type romulan_status(object x)
- return find(x, {TRUCE, HOSTILE, CLOAKING})
- end type
-
- global romulan_status rstat
-
- global f_row rtarg -- Romulan group target
-
- global boolean truce_broken -- was the truce with the Romulans broken?
-
- global boolean gal -- are we in the Galileo?
-
- -----------------
- -- multiple tasks
- -----------------
- global constant NTASKS = 10 -- number of tasks
-
- global constant
- TASK_KEYB = 1, -- keyboard input
- TASK_EMOVE = 2, -- Enterprise move
- TASK_LIFE = 3, -- life support energy consumption
- TASK_DEAD = 4, -- dead body cleanup
- TASK_RSTAT = 5, -- Romulan status change
- TASK_FIRE = 6, -- enemy firing
- TASK_MOVE = 7, -- enemy moving
- TASK_UREM = 8, -- units remaining delayed print
- TASK_DAMAGE = 9, -- damage count-down
- TASK_ENTER = 10 -- enemy ships enter quadrant
-
- global type task(integer x)
- -- is x a valid task number?
- return x >= 1 and x <= NTASKS
- end type
-
- global task current_task -- current task executing
- global sequence tcb -- task activation times
- global sequence eat -- early activation tolerance
- global sequence wait -- waiting time, in seconds, between activations
-
- -----------------
- -- damage report:
- -----------------
- global constant NSYS = 5 -- number of systems that can be damaged
- global constant ENGINES = 1,
- TORPEDOS = 2,
- GUIDANCE = 3,
- PHASORS = 4,
- GALAXY_SENSORS = 5
-
- global constant dtype = {"ENGINES",
- "TORPEDO LAUNCHER",
- "GUIDANCE SYSTEM",
- "PHASORS",
- "SENSORS"}
- global type subsystem(integer x)
- return x >= 1 and x <= NSYS
- end type
-
- global sequence reptime -- time to repair a subsystem
- reptime = repeat(0, NSYS)
-
- type damage_count(integer x)
- return x >= 0 and x <= NSYS
- end type
-
- global damage_count ndmg
-
- --------------
- -- warp speed:
- --------------
- global constant MAX_WARP = 5
-
- global type warp(integer x)
- return x >= 0 and x <= MAX_WARP
- end type
-
- global warp curwarp, wlimit
-
- --------------------------------------
- -- Graphic symbols for some objects --
- --------------------------------------
- global constant
- STAR = '.',
- TORPEDO = '+',
- POD = '*',
- DEFLECTOR = 'd',
- BASE = "<>-<>", -- both halves
- PLANET_TOP = INVISIBLE_CHAR & "OOOO" & INVISIBLE_CHAR,
- PLANET_MIDDLE = "OOOOOO",
- PLANET_BOTTOM = INVISIBLE_CHAR & "OOOO" & INVISIBLE_CHAR,
- ROMULAN_L = "-=##:",
- ROMULAN_R = ":##=-",
- SHUTTLE_L = "-=:",
- SHUTTLE_R = ":=-",
- ENTERPRISE_L = "O-=",
- ENTERPRISE_R = "=-O",
- THOLIAN_L = "-+<",
- THOLIAN_R = ">+-",
- S_KLINGON_L = "O**<",
- S_KLINGON_R = ">**O",
- B_KLINGON_L = "-8**<",
- B_KLINGON_R = ">**8-",
- J_KLINGON_L = "=8**<",
- J_KLINGON_R = ">**8="
-
- -------------------------------------
- -- Enterprise position and direction:
- -------------------------------------
- type enterprise_x_inc(integer x)
- return x >= -3 and x <= +3
- end type
-
- type enterprise_y_inc(integer x)
- return x >= -1 and x <= +1
- end type
-
- global enterprise_x_inc exi
- global enterprise_y_inc eyi
-
- global sequence esym, -- enterprise/shuttle symbol
- esyml, -- enterprise/shuttle facing left
- esymr -- enterprise/shuttle facing right
-
-
- global sequence nobj -- number of each type of object in galaxy
-
- global positive_atom dist, ur
- global object_type urt
- global valid_f_row shooter
- global f_row victim
- global sequence wipeout
- wipeout = {}
-
-